package com.gopay.common.cps.dao.cbrmb.impl;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.cbrmb.CbRmbForceRefundRecordDAO;
import com.gopay.common.domain.cbrmb.CbRmbForceRefundRecord;

@Repository(value="cbRmbForceRefundRecordDAO")
public class CbRmbForceRefundRecordDAOImpl extends BaseDAOImpl<CbRmbForceRefundRecord, String> implements CbRmbForceRefundRecordDAO {

	@Override
	public CbRmbForceRefundRecord findByGopayOrderId(String gopayOrderId) {
		Map<String,Object> params = new HashMap<>();
    	params.put("gopayOrderId", gopayOrderId);

        String hql = "from CbRmbForceRefundRecord m where m.gopayOrderId=:gopayOrderId and m.refundStatus<>'20003'";


        List<CbRmbForceRefundRecord> ss = findByHql(hql,params);
        return (null == ss || 0 == ss.size()) ? null : ss.get(0);
	}
	
    @Override
    public CbRmbForceRefundRecord save(CbRmbForceRefundRecord entity) {
        super.save(entity);
        return entity;
    }
    
    @Override
    public void update(CbRmbForceRefundRecord entity) {
        super.update(entity);
    }

	@Override
	public CbRmbForceRefundRecord checkExist(String gopayOrderId) {
		Map<String,Object> params = new HashMap<>();
    	params.put("gopayOrderId", gopayOrderId);
        String hql = "from CbRmbForceRefundRecord m where m.gopayOrderId=:gopayOrderId and m.refundStatus<>'20003'";
        List<CbRmbForceRefundRecord> ss = findByHql(hql,params);
        return (null == ss || 0 == ss.size()) ? null : ss.get(0);
	}
	

}
